# -*- coding: utf-8 -*-

from BeautifulSoup import BeautifulSoup
import urllib2
import time

class HTMLParser:
    def __init__(self):
        pass

    def parseHTML(self, url):
        t1 = time.clock()

        if (not(url.startswith("http"))):
            url = "http://" + url
            pass

        tags = []
        page = urllib2.urlopen(url)
        soup = BeautifulSoup(page)
        tags.append(len(soup.findAll('h1')))
        tags.append(len(soup.findAll('h2')))
        tags.append(len(soup.findAll('h3')))
        tags.append(len(soup.findAll('div')))
        tags.append(len(soup.findAll('p')))
        tags.append(len(soup.findAll('ul')))
        tags.append(len(soup.findAll('ol')))
        t2 = time.clock()
        print "Parse Time = ", t2 - t1
        return tags
    
##parser = HTMLParser().parseHTML("http://www.crummy.com/software/BeautifulSoup/documentation.html")
